模拟实现strstr
abbcdef
  bcd
#include<assert.h>
char* my_strstr(char* des, const char* sour)
{
	assert(des && sour);
	//双指针同时走
	char* cur1 = des;
	char* cur2 = sour;
	
	char* head = des;//保存起点
	while (*head)
	{
		cur1 = head;
		cur2 = sour;

		while (*cur1 == *cur2 && *cur1 && *cur2)
		{
			cur1++;
			cur2++;
		}
		if (*cur2 == '\0')//第二指针走到尾，找到了
		{
			return head;
		}
		head++;
	}
	return NULL;
}

int main()
{
	char des[] = "abbcdef";
	char sour[] = "bcd";
	char*p=my_strstr(des, sour);
	printf("%s", p);
	return 0;
}


